package com.gitee.feizns.dynamic.convert.impl;

import com.gitee.feizns.dynamic.convert.AbstractConverter;
import com.gitee.feizns.dynamic.convert.ParseToNumberUtils;

/**
 * <b>任意类型到数字的转换器</b>
 * @author feizns
 * @since 2019/5/19 0019
 */
public class ToNumberConverter extends AbstractConverter<Object, Number> {

    /**
     * {@inheritDoc}
     * @param source 原数据
     * @param targetType 目标类型的class对象
     * @return 转换成功后的数据
     */
    @Override
    public Number to(Object source, Class<Number> targetType) {
        return ParseToNumberUtils.to(source, targetType);
    }

    @Override
    public boolean support(Object source, Class<?> targetType) {
        return ParseToNumberUtils.isSupport(targetType);
    }

}
